shuffle_match                package:misc                R Documentation


Description:

		This function is an improved implementation of match_genes. It uses 
		brute force to find the most optimal result. shuffle_match runs 
		match_genes n times and returns the result from match_genes which had 
		the median of the distances between control and gene of interest closest 
		to the chosen optimal distance. 

Usage:

	shuffle_match(all, interest, ...)

Arguments:

		all: data.frame containing all genes that could possibly be a control 
	gene.
		interest: data.frame containing the genes of interest.
		opt: the optimal distance (i.e., the distance from the genes of interest 
	to which the control genes must be close to). Default: opt = 10^4
		n: number of times to run match_genes. Default: n = 100.
		

Details:

		You should vary n depending on how many genes of interest you have.

Value:

		The match data.frame is returned, which comprises of each interest gene 
		matched to a control gene and the relative distance between these two. 
		Note that this is the most optimal result the function could find.

Author(s):

	Murillo Fernando Rodrigues

References:

	None.

Examples:

#match_genes function with both needed data.frames and default parameters.
m = match_genes(all, interest, list = T)
#Check the outcome of match_genes
m

#Running shuffle_match to check whether the order in the interest data.frame alters the outcome. Tipically, doing the shuffle_match is the best way to go, because match_genes algorithm isn't very smart.
s = shuffle_match(all, interest)
#Check the outcome of shuffle_match
s
#Computes the median of the distances between control and interest gene.
md_s = median(r$distance)

#Which result is the closest to the optimal?
(m[[2]]-10^4)
(md_s-10^4)

